﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JobManageCommon.Common
{
  public  class ExportCommon
    {
        /// <summary>
        /// 写入文件
        /// </summary>
        /// <param name="format"></param>
        public static void Exportfun(string batpath, string format)
        {
            FileStream fs2 = new FileStream(batpath, FileMode.Create);
            StreamWriter sw = new StreamWriter(fs2);
            sw.WriteLine(format); 
            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs2.Close();

        }


        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="directoryPath"> 文件夹路径 </param>
        /// <param name="fileName"> 文件名称 </param>
        public static void DeleteDirectory(string directoryPath)
        { 
            //删除文件
            for (int i = 0; i < Directory.GetFiles(directoryPath).ToList().Count; i++)
            { 
                    File.Delete(Directory.GetFiles(directoryPath)[i]); 
            } 
        }
    }
}
